package com.lupan.mutithred.cp5_Future;

import java.util.concurrent.*;

/**
 * 说明：
 *
 * @author lupan
 * @version 2017/5/5 15:42
 */
public class Main {

    public static void main(String[] args) throws InterruptedException {

        Callable<String> callable = new Callable<String>() {
            @Override
            public String call() throws Exception {
                int i=0;
                while (i==0){
                    if(Thread.currentThread().isInterrupted()){
                        System.out.println("线程中断！");
                        throw new InterruptedException("线程中断！");
                    }
                    System.out.println("线程正在运行。。。");
                }
                return "返回值";
            }
        };

        ExecutorService pool = new ThreadPoolExecutor(5,10,0l, TimeUnit.SECONDS,new LinkedBlockingQueue<>());
        Future<String> future = pool.submit(callable);
        Thread.sleep(4000);

        System.out.println(future.cancel(true)+" "+future.isCancelled());
    }

}
